Fix local remove deleting a version in use by a running server#259
Merged
Conversation
`local remove <version>` deleted the binary directory unconditionally, leaving any server running on that version pointing at a deleted binary (issue #257). It now recovers orphaned servers, refuses to remove a version that a running server is using (new VersionInUse error listing the server names), and accepts --force to stop the running server(s) first. Reuses the existing server remove guard pattern. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #257.
Problem
chctl local remove <version>deleted the installed binary directory unconditionally. If a local server was running on that version, the binary was pulled out from under it —local removereported success whilelocal server liststill showed the server running, now pointing at a deleted binary.Fix
local remove <version>now:VersionInUseerror that lists the running server name(s): "Version X is in use by running server(s): default. Stop them first, or pass --force." (exit code 1, nothing deleted).--forceto stop the running server(s) first (printingStopped server '<name>'), then proceed with the existing default-version/symlink cleanup and removal.Reuses the same guard pattern as
server remove(recover_current_project_servers,list_running_servers,kill_server). Detection/stop is current-project scoped, consistent with those helpers, which covers the reported in-project bug.Changes
src/error.rs— newVersionInUse { version, servers }variant (+ exit-code test).src/local/cli.rs—--forceflag onRemove, updated help text, two parse tests.src/local/mod.rs— running-server guard inremove().README.md— documented the guard and--force.Verification
cargo buildandcargo clippyclean (no warnings).cargo test -p clickhousectl— all passing, including the new parse and exit-code tests.🤖 Generated with Claude Code
Note
Low Risk
Localized CLI safety change around version removal; reuses existing server stop/discovery helpers with tests and docs.
Overview
clickhousectl local removeno longer deletes an installed ClickHouse binary if a local server in the current project is still running on that version. It recovers orphaned servers, lists matching running instances, and fails withVersionInUse(exit 1) naming those servers unless you stop them first.Adds
--forceonlocal removeto stop those servers via the existingkill_serverpath, printStopped server '<name>', then run the usual default-version / symlink cleanup and directory removal. CLI help, README, a new error variant (+ exit-code test), andRemoveparse tests document and cover the behavior.Reviewed by Cursor Bugbot for commit 8b5ef18. Bugbot is set up for automated code reviews on this repo. Configure here.